import dotenv from "dotenv";

// 加载环境变量
dotenv.config();

const config = {
  // 服务器配置
  server: {
    port: process.env.PORT || 3001,
    env: process.env.NODE_ENV || "development",
  },

  // 数据库配置
  database: {
    uri: process.env.MONGODB_URI || "mongodb://localhost:27017/sqtracker",
  },

  // JWT配置
  jwt: {
    secret: process.env.JWT_SECRET || "your-secret-key",
    expiresIn: process.env.JWT_EXPIRES_IN || "7d",
  },

  // 推荐服务配置
  recommender: {
    url: process.env.RECOMMENDER_URL || "http://localhost:8080/api/v1",
    timeout: parseInt(process.env.RECOMMENDER_TIMEOUT || "5000", 10),
  },

  // 跨域配置
  cors: {
    origin: process.env.CORS_ORIGIN || "*",
    methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
    allowedHeaders: ["Content-Type", "Authorization"],
  },

  // 日志配置
  logging: {
    level: process.env.LOG_LEVEL || "info",
    format: process.env.LOG_FORMAT || "dev",
  },
};

export default config;
